<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #app {
            border: 1px solid green;
            width: 300px;
            padding: 50px 0;
        }
        
        .box {
            display: flex;
            justify-content: space-around;
            flex-wrap: wrap;
        }
        
        p {
            width: 300px;
            text-align: center;
            font-size: 25px;
        }
        
        .box div {
            width: 80px;
            line-height: 40px;
            text-align: center;
            color: #fff;
            background-color: #3883e9;
        }
    </style>
</head>

<body>
    <div id="app">
        <jia :msg='num'></jia>
    </div>
    <template id="item">
        <div class="box">
            <p>{{msg}}</p>
            <div @click="add()">增加1</div>
            <div @click="minus()">减小1</div>
        </div>
    </template>
</body>

<script src="js/vue.js"></script>
<script>
    let vm = new Vue({
        el: "#app",
        data: {
            num: 0
        },
        components: {
            jia: {
                props: ['msg'],
                template: "#item",
                methods: {
                    add() {
                        this.msg++
                    },
                    minus() {
                        this.msg--
                    }
                }
            },

        }
    })
</script>

</html>